import { request } from "@utils/http"    //引入axios实例
import {Key} from "react"                //引入react的类型 Key

//引入类型
import type {
    getHosSetListParamsType,      //获取分页列表参数类型 
    getHosSetListReturnType,      //获取分页列表返回值类型 
    addHospitalParamType,         //添加医院参数类型 
    getHosSetListItemsType,       //根据id获取医院返回值类型 
    updateHospitalParamType,      //修改医院的参数类型
} from './model/hospitalSetTypes'


//医院设置中 获取分页列表请求
export const getHosSetListRequest = ({ page, limit, hosname, hoscode }:getHosSetListParamsType) => {
    return request.get<any , getHosSetListReturnType >(`/admin/hosp/hospitalSet/${page}/${limit}`, {
        params: {
            hosname,
            hoscode
        }
    })
}


//医院设置中 , 添加医院请求
export const addHospitalRequest = (data:addHospitalParamType) => {
    //添加医院请求不需要返回值,所以返回h值类型为null
    return request.post<any , null>("/admin/hosp/hospitalSet/save" , data)
}


//医院设置中 , 根据id获取某个医院的详细设置
export const getHosSetFromIdRequest = (id:string) => {
    return request.get<any , getHosSetListItemsType>(`/admin/hosp/hospitalSet/get/${id}`)
}


//医院设置中 , 修改医院请求
export const updateHosSetFromIDrequest = (data:updateHospitalParamType) => {
    return request.put<any , null>("/admin/hosp/hospitalSet/update" , data)
}


//医院设置中 , 删除医院请求
export const deleteHosSetFromIdRequest = (id:number) => {
    return request.delete<any ,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

//医院设置中 , 批量删除医院请求
export const deleteAllHosSetFromIdsRequest = (ids:Key[]) => {
    return request.delete<any ,null>(`/admin/hosp/hospitalSet/batchRemove` , {
        data: ids
    })
}

